/*
 Navicat Premium Data Transfer

 Source Server         : 华为云
 Source Server Type    : SQL Server
 Source Server Version : 12002000
 Source Host           : 122.112.249.251:1433
 Source Catalog        : dbxt
 Source Schema         : dbo

 Target Server Type    : SQL Server
 Target Server Version : 12002000
 File Encoding         : 65001

 Date: 05/11/2020 13:41:26
*/


-- ----------------------------
-- Table structure for dgMsg
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[dgMsg]') AND type IN ('U'))
	DROP TABLE [dbo].[dgMsg]
GO

CREATE TABLE [dbo].[dgMsg] (
  [id] int  IDENTITY(1,1) NOT NULL,
  [msgBody] text COLLATE Chinese_PRC_CI_AS  NULL,
  [msgTime] datetime2(7)  NULL,
  [msgType] varchar(255) COLLATE Chinese_PRC_CI_AS  NULL,
  [msgTag] varchar(255) COLLATE Chinese_PRC_CI_AS  NULL,
  [flag] int  NULL,
  [msgUser] varchar(255) COLLATE Chinese_PRC_CI_AS  NULL,
  [msgTitle] varchar(255) COLLATE Chinese_PRC_CI_AS  NULL
)
GO

ALTER TABLE [dbo].[dgMsg] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'消息内容',
'SCHEMA', N'dbo',
'TABLE', N'dgMsg',
'COLUMN', N'msgBody'
GO

EXEC sp_addextendedproperty
'MS_Description', N'消息产生时间',
'SCHEMA', N'dbo',
'TABLE', N'dgMsg',
'COLUMN', N'msgTime'
GO

EXEC sp_addextendedproperty
'MS_Description', N'消息类型（重要不重要）',
'SCHEMA', N'dbo',
'TABLE', N'dgMsg',
'COLUMN', N'msgType'
GO

EXEC sp_addextendedproperty
'MS_Description', N'消息标签',
'SCHEMA', N'dbo',
'TABLE', N'dgMsg',
'COLUMN', N'msgTag'
GO

EXEC sp_addextendedproperty
'MS_Description', N'是否启用',
'SCHEMA', N'dbo',
'TABLE', N'dgMsg',
'COLUMN', N'flag'
GO

EXEC sp_addextendedproperty
'MS_Description', N'是否推送到指定人员',
'SCHEMA', N'dbo',
'TABLE', N'dgMsg',
'COLUMN', N'msgUser'
GO

EXEC sp_addextendedproperty
'MS_Description', N'消息标题',
'SCHEMA', N'dbo',
'TABLE', N'dgMsg',
'COLUMN', N'msgTitle'
GO


-- ----------------------------
-- Table structure for dgMsgUser
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[dgMsgUser]') AND type IN ('U'))
	DROP TABLE [dbo].[dgMsgUser]
GO

CREATE TABLE [dbo].[dgMsgUser] (
  [id] int  IDENTITY(1,1) NOT NULL,
  [loginName] varchar(255) COLLATE Chinese_PRC_CI_AS  NOT NULL,
  [msgId] int  NOT NULL,
  [user_Vew] varchar(255) COLLATE Chinese_PRC_CI_AS  NULL,
  [viewTime] datetime2  NULL
)
GO

ALTER TABLE [dbo].[dgMsgUser] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'用户唯一登录名称',
'SCHEMA', N'dbo',
'TABLE', N'dgMsgUser',
'COLUMN', N'loginName'
GO

EXEC sp_addextendedproperty
'MS_Description', N'消息id',
'SCHEMA', N'dbo',
'TABLE', N'dgMsgUser',
'COLUMN', N'msgId'
GO

EXEC sp_addextendedproperty
'MS_Description', N'用户是否查看',
'SCHEMA', N'dbo',
'TABLE', N'dgMsgUser',
'COLUMN', N'user_Vew'
GO

EXEC sp_addextendedproperty
'MS_Description', N'查看时间',
'SCHEMA', N'dbo',
'TABLE', N'dgMsgUser',
'COLUMN', N'viewTime'
GO


-- ----------------------------
-- Primary Key structure for table dgMsg
-- ----------------------------
ALTER TABLE [dbo].[dgMsg] ADD CONSTRAINT [PK__dg_msg__3213E83FD007A83E] PRIMARY KEY CLUSTERED ([id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table dgMsgUser
-- ----------------------------
ALTER TABLE [dbo].[dgMsgUser] ADD CONSTRAINT [PK__dg_msg_u__3213E83F9A560647] PRIMARY KEY CLUSTERED ([id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Foreign Keys structure for table dgMsgUser
-- ----------------------------
ALTER TABLE [dbo].[dgMsgUser] ADD CONSTRAINT [fk_dg_msg_user_dg_msg_1] FOREIGN KEY ([msgId]) REFERENCES [dbo].[dgMsg] ([id]) ON DELETE NO ACTION ON UPDATE NO ACTION
GO

